//
//  LineTableViewCell.swift
//  scfriend
//
//  Created by wulanzhou on 2017/9/1.
//  Copyright © 2017年 wulanzhou. All rights reserved.
//

import UIKit

class LineTableViewCell: UITableViewCell {
    
    
    private lazy var topLine:UILabel = {
    
        let lab:UILabel = UILabel.init(frame: CGRect(x: 0, y: 0, width: self.bounds.size.width, height: 0.5))
        lab.backgroundColor = UIColor.withRGBA(222, 222, 222)
        return lab
    
    }()
    
    private lazy var bottomLine:UILabel = {
        
        let lab:UILabel = UILabel.init(frame: CGRect(x: 0, y: self.bounds.size.height - 0.5, width: self.bounds.size.width, height: 0.5))
        lab.backgroundColor = UIColor.withRGBA(222, 222, 222)
        return lab
        
    }()
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        self.topLine.backgroundColor = UIColor.withRGBA(222, 222, 222) //防止选中时，放到上面的view消失
        self.bottomLine.backgroundColor = self.topLine.backgroundColor
    }
    
    override func setHighlighted(_ highlighted: Bool, animated: Bool) {
        super.setHighlighted(highlighted, animated: animated)
        self.topLine.backgroundColor = UIColor.withRGBA(222, 222, 222)//防止高亮时，放到上面的view消失
        self.bottomLine.backgroundColor = self.topLine.backgroundColor
    }
    
    init(style:UITableViewCellStyle,reuseIdentifier:String,showTopLine:Bool) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.addSubview(self.bottomLine)
        self.addSubview(self.topLine)
        self.topLine.isHidden = showTopLine
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        var r:CGRect = self.bottomLine.frame
        r.origin.y = self.bounds.size.height - r.size.height
        r.size.width = self.bounds.size.width
        self.bottomLine.frame = r
        
        r = self.topLine.frame
        r.size.width = self.bounds.size.width
        self.topLine.frame = r
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

   

}
